package com.bian.controller;

import com.bian.config.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {
    @GetMapping("/demo")
    public String demo() {
        return "demo";
    }

    @GetMapping("/sendToUser")
    public AjaxResult sendToUser(String userId, String message) {
        WebSocketServer.sendToUser(userId, message);
        return AjaxResult.success();
    }

    @GetMapping("/sendToAll")
    public AjaxResult sendToAll(String message) {
        WebSocketServer.sendToAll(message,null);
        return AjaxResult.success();

    }
}
